<!doctype html>
<html class="no-js fixed-layout">
<head>
  <#include "head.ftl">
</head>
<body>
<#include "header.ftl">


<#include "menu.ftl">

  <!-- content start -->
  <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding">
        <ol class="am-breadcrumb">
		  <li><a href="${info.domain}" class="am-icon-home">首页</a></li>
		  <li><a href="${info.domain}web">网站</a></li>
		  <li><a href="${info.domain}web">${web.name}</a></li>
		  <li class="am-active">目标网址</li>
		</ol>
      </div>

   <div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
          <div class="am-btn-toolbar">
            <div class="am-btn-group am-btn-group-xs">
              <a  href="${info.domain}web/addweburl/${web.id}" class="am-btn am-btn-default am-btn-primary"><span class="am-icon-plus"></span> 新增网址</a>
              <button onclick="updateWeburl()" type="button" class="am-btn am-btn-default am-btn-primary  am-disabled am-btn-tngou"><span class="am-icon-save"></span> 编辑网址</button>
              <button onclick="deleteWeburl(null)" type="button" class="am-btn am-btn-default am-btn-primary  am-disabled am-btn-tngou"><span class="am-icon-trash-o"></span> 删除网子</button>
           
            </div>
          </div>
        </div>
        <div class="am-u-sm-12 am-u-md-3">
         
        </div>
        <div class="am-u-sm-12 am-u-md-3">
          <div class="am-input-group am-input-group-sm">
           
          <span class="am-input-group-btn">
            <a href="${info.domain}web" type="button" class="am-fr am-btn am-btn-default am-btn-sm">返回</a>
          </span>
          </div>
        </div>
      </div>  

 <div class="am-g">
        <div class="am-u-sm-12">
          <table class="am-table am-table-bd am-table-striped admin-content-table">
            <thead>
            <tr>
             <th  style="width:50px;"></th>
              <th>URL</th><th>有效数据</th><th>无效数据</th><th>相同标识</th><th>管理</th>
            </tr>
            </thead>
            <tbody>
            
            <#list page.list as item>
            <tr>
            <td>
            <label class="am-checkbox">
  			<input type="checkbox" value="${item.id}" data-am-ucheck>
			</label>
            </td>
            <td>${item.url}</td>
            <td>${item.key_value}</td>
            <td>${item.invalid_data}</td>
             <td>${item.unique_value}</td>
              <td>
                <div class="am-dropdown" data-am-dropdown>
                  <button class="am-btn am-btn-default am-btn-xs am-dropdown-toggle" data-am-dropdown-toggle><span class="am-icon-cog"></span> <span class="am-icon-caret-down"></span></button>
                  <ul class="am-dropdown-content">
                   
                    <li><a href="${info.domain}web/updateweburl/${item.id}">编辑网址</a></li>
                    <li><a href="javascript:deleteWeburl(${item.id})">删除网址</a></li>
                  
                  </ul>
                </div>
              </td>
            </tr>
            </#list>
            </tbody>
          </table>
        </div>
        <#include "page.ftl">
      </div>


    </div>

 <#include "footer.ftl">
<script type="text/javascript">


 $('.am-table tr').on('click',function(){
   		
	   if($(this).find(".am-checkbox input[type=checkbox]").is(':checked'))
	   {	   	 
	   	  $(this).find(".am-checkbox input[type=checkbox]").uCheck('uncheck');
	   	  $('.am-table tr').removeClass("am-active");
	   	   $(".am-btn-tngou").addClass("am-disabled");
	   }else
	   {
	     $('.am-checkbox input[type=checkbox]').uCheck('uncheck');
	     $('.am-table tr').removeClass("am-active");
	     $(this).find(".am-checkbox input[type=checkbox]").uCheck('check');
	     $(this).addClass("am-active"); 
	      $(".am-btn-tngou").removeClass("am-disabled");
	   }

  	});
  	
  	
function dialogSelect(){
  	   AMUI.dialog.alert({
			    title: '提示',
			    content: '请选择数据'
			});
  	}
  	
 function deleteWeburl(id)
  	{
  	  if(!id)id=$('.am-checkbox input[type=checkbox]:checked').val();
  	  if(id)
  	  {
  	  	AMUI.dialog.confirm({
		    title: '安全提示',
		    content: '确定需要删除选择的数据？',
		    onConfirm: function() {
		       var $loading = AMUI.dialog.loading();
		     	$.post("${info.domain}api/deleteweburl", { id: id} ,
		     	function(json){
		     	 $loading.modal('close');
				      if(json.status)
				      {				    
						  window.location.reload();
				      }else
				      {
				         AMUI.dialog.alert({
							    title: '提示',
							    content: json.msg
							});
				      }
				 });
		    },
		    onCancel: function() {
		     
		    }
		});
  	  	
  	  }else
  	  {
  	  		dialogSelect();
  	  }
  	
  	} 	
  function updateWeburl()
  	{
  	  var id=$('.am-checkbox input[type=checkbox]:checked').val();
  	  if(id)
  	  {
  	  	window.location.href='${info.domain}web/updateweburl/'+id;
  	  }else
  	  {
  	  	dialogSelect();
  	  }
  	
  	}	 	 	
</script>

</body>
</html>
